package cn.quickcode.monitor.ui.provider;

import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ITableColorProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;

import cn.quickcode.monitor.SMR;
import cn.quickcode.monitor.model.Dbm;
import cn.quickcode.monitor.model.Ntm;
import cn.quickcode.monitor.model.ModelSuppert;
import cn.quickcode.monitor.model.Srm;
import cn.quickcode.monitor.model.Stm;

public class SMLabelProvider extends LabelProvider implements ITableLabelProvider,ITableColorProvider,IFontProvider
{

	@Override
	public Image getColumnImage(Object element, int columnIndex)
	{
		return null;
	}
	
	@Override
	public String getColumnText(Object element, int columnIndex)
	{
		if (element instanceof Dbm)
		{
			switch (columnIndex)
			{
			case 0:
				return ((Dbm) element).getId().toString();
			case 1:
				return ((Dbm) element).getAlias();
			case 2:
				return ((Dbm) element).getIp();
			case 3:
				return ((Dbm) element).getStatus();
			case 4:
				return ((Dbm) element).getMessage();
			}
		}
		else if (element instanceof Stm)
		{
			switch (columnIndex)
			{
			case 0:
				return ((Stm) element).getId().toString();
			case 1:
				return ((Stm) element).getName();
			case 2:
				return ((Stm) element).getUrl();
			case 3:
				return ((Stm) element).getStatus();
			}
		}
		else if (element instanceof Srm)
		{
			switch (columnIndex)
			{
			case 0:
				return ((Srm) element).getId().toString();
			case 1:
				return ((Srm) element).getName();
			case 2:
				return ((Srm) element).getUrl();
			case 3:
				return ((Srm) element).getStatus();
			}
		}
		else if (element instanceof Ntm)
		{
			switch (columnIndex)
			{
			case 0:
				return ((Ntm) element).getId().toString();
			case 1:
				return ((Ntm) element).getName();
			case 2:
				return ((Ntm) element).getIp();
			case 3:
				return ((Ntm) element).getStatus();
			}
		}
		return "";
	}
	@Override
	/**
	 * 设置列前景色
	 */
	public Color getForeground(Object element, int columnIndex)
	{
		switch(columnIndex)
		{
		case 3:
			return SMR.GET_COLOR(((ModelSuppert)element).getStatus());
		}
		return null;
	}

	@Override
	/**
	 * 设置列背景色
	 */
	public Color getBackground(Object element, int columnIndex)
	{
		return null;
	}

	@Override
	/**
	 * 设置字体
	 */
	public Font getFont(Object element)
	{
		return null;
	}
	
}
